package com.demo.cotroller;

import com.demo.bean.Man;
import com.demo.bean.Student;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by wangzhanjin on 2018/6/8.
 */
@Controller
@RequestMapping("/model")
public class ModelMapperController {

    /**
     * 相当于new一个Bean，在application配置
     * 也可以在@Configuration注解的类中配置个（相当于xml中new）
     */
    @Autowired
    private ModelMapper modelMapper;


    @RequestMapping()
    @ResponseBody
    public String hello() {
        Man man = Man.someOne();
        Student student = modelMapper.map(man, Student.class);
        student.setTall("hansome 足够高");
        return student.toString();
    }

}
